Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OverflowError more informative #22761

Merged
merged 1 commit into from
Aug 8, 2017
Merged

Make OverflowError more informative #22761

merged 1 commit into from
Aug 8, 2017

Conversation

timholy
Copy link
Member

@timholy timholy commented Jul 11, 2017

The last of the big 3 inscrutable error messages (InexactError, DomainError, and OverflowError). This one is a little messier than the other two because there's one C creator that I didn't easily see how to change; when I previously tried to throw a more sophisticated error message from C (#20005) it didn't go very well. So here I just took the expedient approach and created two distinct classes of Exceptions, one inscrutable one to be thrown from the C code, and a nice, easy-to-debug one from Julia.

@ararslan ararslan added the error handling Handling of exceptions by Julia or the user label Jul 11, 2017
@tkelman
Copy link
Contributor

tkelman commented Jul 12, 2017

looks mostly fine to me, no ideas on the separate from-C version
@nanosoldier runbenchmarks(ALL, vs = ":master")

@timholy
Copy link
Member Author

timholy commented Jul 12, 2017

Thanks for triggering nanosoldier.

no ideas on the separate from-C version

Since this the last in the chain of PRs, I'm fine with leaving this open for a while to see if any objections arise.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

base/checked.jl Outdated
@@ -90,16 +90,18 @@ The overflow protection may impose a perceptible performance penalty.
function checked_neg(x::T) where T<:Integer
checked_sub(T(0), x)
end
throw_overflowerr_negation(x) = (@_noinline_meta;
throw(OverflowError("cannot compute -x for x = $x::$(typeof(x))")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, it would be useful to mention "checked" somewhere, so that it's clear this is not an error from the standard - function. Same for abs.

NEWS.md Outdated
[msg])` prints as `ERROR: DomainError with val:\nmsg`. ([#20005],
[#22751])
"ERROR: InexactError: func(type, -3)", `DomainError(val,
[msg])` prints as "ERROR: DomainError with val:\nmsg", and `OverflowError(msg)` prints as "Error: OverflowError: msg". ([#20005],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps wrap this line at the comma?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all 3 capitalize the ERROR don't they? or is there a discrepancy somehow?

@timholy
Copy link
Member Author

timholy commented Aug 7, 2017

@nanosoldier runbenchmarks(ALL, vs = ":master")

@timholy
Copy link
Member Author

timholy commented Aug 7, 2017

Something seems wrong with CI right now?

@iblislin
Copy link
Member

iblislin commented Aug 7, 2017

bsd ci error is #23143
feel free to press the rebuild button.

@timholy
Copy link
Member Author

timholy commented Aug 7, 2017

It's more than that, the Linux travis bots seem to be having trouble downloading UnicodeData.txt.

@fredrikekre
Copy link
Member

That failure has been seen a lot recently on Travis I feel like, perhaps you could restart and hope for the best? 🤷‍♂️

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@tkelman
Copy link
Contributor

tkelman commented Aug 7, 2017

Given staticfloat/cache.julialang.org#16, that should be hitting our cache server. I'm not sure why it didn't, or why that has been failing again.

@timholy
Copy link
Member Author

timholy commented Aug 7, 2017

OK, that's a nice nanosoldier run. Not quite sure why I got performance enhancements, but I'll take it. (I manually checked the regressions in the first nanosoldier run; they were real, but I fixed them in this version, and perhaps there were collateral benefits.)

Appveyor likes this and I can also verify tests pass on Linux locally. I'll try restarting the travis and BSD bots, but if they fail again I'm sorta inclined to hit merge anyway?

@StefanKarpinski
Copy link
Member

👍 @travis-ci has been a sh*tshow since they decided to oversubscribe all their VMs, rendering their service completely and utterly useless to us despite the fact that we are paying customers 😡.

src/init.c Outdated
@@ -785,7 +785,7 @@ void jl_get_builtin_hooks(void)
jl_errorexception_type = (jl_datatype_t*)core("ErrorException");
jl_stackovf_exception = jl_new_struct_uninit((jl_datatype_t*)core("StackOverflowError"));
jl_diverror_exception = jl_new_struct_uninit((jl_datatype_t*)core("DivideError"));
jl_overflow_exception = jl_new_struct_uninit((jl_datatype_t*)core("OverflowError"));
jl_c_overflow_exception = jl_new_struct_uninit((jl_datatype_t*)core("COverflowError"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems sort of odd to have two overflow exception types. It would be nicer to use something like:

jl_c_overflow_exception = core("overflow_error_from_c")
const overflow_error_from_c = OverflowError(ErrorException(""))

But there's only one active use of this in src (in jl_compute_field_offsets), so it's perhaps better just to delete this entirely and use jl_errorf there.

@timholy timholy merged commit 14ad339 into master Aug 8, 2017
@timholy timholy deleted the teh/overflow branch August 8, 2017 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants